import { useEffect } from 'react';
import { MessageInstance, MessagePlugin, message } from 'tdesign-react';

class GMessage {
  public messageApi: MessageInstance | null = null;

  public setMessageApi(messageApi: MessageInstance | null) {
    this.messageApi = messageApi;
  }
}

const globalMessage = new GMessage();
export { globalMessage };

export default function GlobalMessage() {
  // const [messageApi, contextHolder] = messageApi.useMessage();
  MessagePlugin;

  useEffect(() => {
    // globalMessage.setMessageApi(messageApi);
    return () => {
      globalMessage.setMessageApi(null);
    };
  }, []);

  return <>{/* // {contextHolder} */}</>;
}
